home *** CD-ROM | disk | FTP | other *** search
- Listing 1 - class definition for a generic queue using void * elements
-
- //
- // genq3.h - generic queue using void *
- // elements and an iteration function
- //
-
- #include <iostream.h>
-
- class genq
- {
- public:
- genq();
- ~genq();
- void append(void *e);
- void apply(void f(void *p));
- void clear();
- int remove(void *&e);
- private:
- struct cell
- {
- cell(void *e, cell *p);
- cell *next;
- void *element;
- };
- cell *first, *last;
- };
-
- inline genq::cell::cell(void *e, cell *p)
- : element(e), next(p)
- {
- }
-
- inline genq::genq() : first(0), last(0)
- {
- }
-
- inline genq::~genq()
- {
- clear();
- }
-